<?php
class Application_Model_Filter_FinancialSearch {
    /**
     * 快速搜索
     */
    public $quick;  
     /**
     * 开始时间
     */
    public $starttime;
    /**
     * 结束时间
     */
    public $endtime;
    /**
     * 对象类型
     */
    public $objectType;
    /**
     * 最大金额
     */
    public $moneyMax;
    /**
     * 最小金额
     */
    public $moneyMin;
    /**
     * 金额操作类型
     */
    public $moneyType;
    /**
     * 状态
     */
    public $statusid;
            
    
    function getSearchFileds() {
        $where=array(); 
        $and = "";
        if($this->quick != ""){
            $userItem = Application_Model_User::getByNikeNameStore($this->quick);
            if ($userItem != null) {
                $inuserid = "(";
                foreach ($userItem as $userval) {
                    $inuserid.= $userval->id . ",";
                }
                $inuserid.= "0)";
                $where[$and . " userId in "] = $inuserid;
            } else {
                $where[$and . " userId = "] = $this->quick;
            }
            $and = " and ";
        }
        
        if($this->starttime != ""){
            $where[$and." dateCreated > "] = $this->starttime;
            $and = " and ";
        }
        if($this->endtime != ""){
            $where[$and." dateCreated <= "] = $this->endtime." 23:59:59";
            $and = " and ";
        }
        
        if($this->objectType != ""){
            $where[$and." objectType = "] = $this->objectType;
            $and = " and ";
        }
        
        if($this->moneyMin != ""){
            $where[$and." money >= "] = $this->moneyMin;
            $and = " and ";
        }
        
        if($this->moneyMax != ""){
            $where[$and." money <= "] = $this->moneyMax;
            $and = " and ";
        }
        
        if($this->moneyType != ""){
            $where[$and." needAddMoney = "] = $this->moneyType;
            $and = " and ";
        }
        
        if($this->statusid !== "" && $this->statusid !== null){
            $where[$and." status = "] = $this->statusid;
            $and = " and ";
        }
        
        return $where;
    }
    
}

